import { RouteConfig } from "./RouteConfig";
import { RouteInterface } from "./routeInterface";

export class RouteBaseImpl implements RouteInterface {
	
	
	navigateTo(option){
		
		let page = RouteConfig.pages[option.name]
		
		//过滤非法路径
		if(!page){
			option.name = "home"
			page = RouteConfig.pages[option.name]
		}
		
		//过滤登录状态
		page.login = page.login || false
		if(page.login){
			//过滤登录状态
			console.log("过滤登录状态")
			option.name = "login"
			page = RouteConfig.pages[option.name]
		}
		
		option.url = "/" + page.path
		
		option.events = option.events || {}
		
	
	}
	reLaunchTo(option){
		
		let page = RouteConfig.pages[option.name]
		
		//过滤非法路径
		if(!page){
			option.name = "home"
			page = RouteConfig.pages[option.name]
		}
		
		//过滤登录状态
		page.login = page.login || false
		if(page.login){
			//过滤登录状态
			console.log("过滤登录状态")
			option.name = "login"
			page = RouteConfig.pages[option.name]
		}
	
		option.url = "/" + page.path
		
		option.events = option.events || {}
	}
	
	goBack(option){
		
		
	
	}
}